<template>
    <div>
        <input type="button" value="添加" @click="router.push('/gaoadd')" class="btn btn-info"/> <br/>
        标题<input type="text" v-model="queryinfo.title"/>
        公告类型
        <select v-model="queryinfo.leixingid">
            <option value="">请选择</option>
            <option value="服务协议">服务协议</option>
            <option value="养老协议">养老协议</option>
        </select>
        <input type="button" value="查询" @click="getlist" class="btn btn-primary"/>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>Id</td>
                    <td>标题</td>
                    <td>分类</td>
                    <td>图片</td>
                    <td>状态</td>
                    <td>发布时间</td>
                </tr>
                <tr v-for="item in data.list" :key="item.Id">
                    <td>{{ item.Id }}</td>
                    <td>{{ item.Title }}</td>
                    <td>{{ item.Leixingid }}</td>
                    <td><img :src="item.Photo" width="100" height="100" alt=""/></td>
                    <td>{{ item.State?"显示":"隐藏" }}</td>
                    <td>{{ moment(item.CreateTime).format("YYYY-MM-DD hh:mm:ss") }}</td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,reactive, onMounted} from 'vue'
import axios from 'axios';
import moment from 'moment';
import {useRouter,useRoute}from 'vue-router'
const router=useRouter();
const route=useRoute();

let data:any=reactive({
    list:[],
})

let queryinfo:any=reactive({
    title:'',
    leixingid:'',
})

onMounted(()=>{
    getlist();
})

const getlist=()=>{
    axios({
        url:'/api/Gonggao/Getgonggao',
        method:'get',
        params:queryinfo
    })
    .then(res=>{
        console.log(res);
        data.list=res.data;
    })
    .catch(err=>{
        console.log(err);
    })
}

</script>

<style scoped>

</style>